//! @Author: DengLibin
//! @Date: Create in 2025-02-07 12:13:54
//! @Description: 一些工具应用
//!
pub mod dong_tai_data;
pub mod down_file_record;
pub mod hubei_data_parse;
pub mod ribao_json;
pub mod store_file_record;
pub mod store_vec_data;
pub mod tian_fu_mongo;
pub mod tian_fu_mongo_doc;
pub mod migration_ai_paragraph;

use chrono::NaiveDateTime;
use derive_builder::Builder;

use proc_macro::table_name;
use proc_macro::{GetFieldNames, HaveFieldType, StructToMap};
use serde::{Deserialize, Serialize};
use sqlx::FromRow;

use my_trait::MustHaveFieldType;
use my_trait::MustHaveTableName;
use my_trait::Struct2Map;

use crate::sys::serialize_fn::{deserialize_naive_date_time, serialize_naive_date_time};

#[derive(
    Debug, FromRow, Serialize, Deserialize, Builder, HaveFieldType, GetFieldNames, StructToMap,
)]
#[table_name("file_record")]
pub struct FileRecord {
    pub id: i64,
    pub path: String,
}

#[derive(
    Debug, FromRow, Serialize, Deserialize, Builder, HaveFieldType, GetFieldNames, StructToMap,
)]
#[table_name("ai_paragraph_vec")]
pub struct AiParagraphVec {
    pub id: i64,
    pub deleted: bool, // tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否删除(逻辑删除)',
    #[serde(
        default,
        serialize_with = "serialize_naive_date_time",
        deserialize_with = "deserialize_naive_date_time",
        skip_serializing_if = "Option::is_none"
    )]
    pub create_time: Option<NaiveDateTime>,
    pub update_time: Option<NaiveDateTime>, //` datetime DEFAULT NULL COMMENT '更新时间',
    pub create_by: i64,                     //` bigint DEFAULT NULL COMMENT '创建人',
    pub update_by: i64,                     //` bigint DEFAULT NULL COMMENT '更新人',
    pub table_id: i64,                      // bigint DEFAULT NULL COMMENT '库id',
    pub es_id: i64,                         // bigint DEFAULT NULL COMMENT '来源数据id',
    pub file_id: Option<i64>,                       //bigint DEFAULT NULL COMMENT '来源文件id',
    pub file_md5: Option<String>, // varchar(127) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '来源文件md5',
    pub paragraph: Option<String>, //` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '段落文本',
    pub vec: Option<String>, //` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '段落向量',
    pub status: i32,         // int DEFAULT NULL COMMENT '状态',
    pub ai_id: Option<i64>,          // bigint DEFAULT NULL COMMENT '当前这条素材的id',
    pub text_paragraph_id: Option<i64>, //bigint DEFAULT NULL,
    pub chinese: Option<String>, //` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci,
    pub lang: Option<i32>,           // int NOT NULL DEFAULT '0',
}
